import os 
from PIL import Image


title = input("Plase input the TITLE：\n")

baseUrl = "./base.png"
baseImage = Image.open(baseUrl)
baseW,baseH = baseImage.size

picNo = -1 

for root, dirs, files in os.walk(".", topdown=False):
    for name in files:         
        if(name[-3:] == "png"):
            imageUrl = name 
            #判断文件是否是图片，因为当前文件夹中存有当前程序文件
            print(os.path.join(root, name))     
            #打开图像文件
            im = Image.open(imageUrl)
            w,h = im.size
            print(w,h)

            left = (w-baseW)/2
            up = (h-baseH)/2
            right = w - left
            below = h - up
            reSize = (left,up,right,below)

            cropIm = im.crop(reSize)
            
            cropIm.save(title + imageUrl)
